#ifndef _GMM_H
#define _GMM_H

#include <vector>
#include <cmath>

class GMM
{
public:
    void Init(const std::vector<double> &inputData,const int clustNum=5,double eps=0.01,double max_steps=20);
    //!@brief given a dataset, compute a Gaussian mixture model
    void train();
    //!@brief predict which cluster input belong to with Gaussian mixture model
    int     predicate(double input);
    void    print();
protected:
    int clusterNum;
    std::vector<double> means;
    std::vector<double> means_bkp; // for compare between last result and current result
    std::vector<double> sigmas;
    std::vector<double> probilities;
    std::vector<std::vector<double> > memberships;
    std::vector<double> data;
    int dataNum;
    double epslon;
    double max_steps;
private:
    double gauss(const double x,const double m,const double sigma);
};

#endif
